package detect;

import interfaces.Detect;

import java.util.Map;

import org.jsoup.nodes.Document;

import entities.Domain;

public class DetectAdsense implements Detect {
	@Override
	public void getInfo(Map<String, Object> obj) {
		String adsAccount = "";
		Document doc = (Document) obj.get("doc");
		Domain domain = (Domain) obj.get("domain");

		try {
			String content = doc.html();

			int begin = content.indexOf("google_ad_client = \"");
			if (begin > 0) {
				begin += "google_ad_client = \"', '".length();
				int end = content.indexOf("\"", begin);
				adsAccount = content.substring(begin, end);
			}
		} catch (Exception e) {

		}
		domain.setAdsense(adsAccount);
	}
}
